<template>
	<view>
		<view class="card">
			<view class="title">
				子组件B
			</view>
			<view class="area">
				<text>ComA组件传进来的值：</text>
				<text style="background-color: blue; color: white;">{{result}}</text>
			</view>
			<view class="smart-flex area">
				<text>回传值：</text>
				<input type="text" v-model="callbackValue" style="color: yellow;background-color: darkgray;"/>
				<button @click="sendOutside()" size="mini">回传</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "PassvalueComB",
		data() {
			return {
				result:""
			};
		},
		
		methods:{
			sendOutside() {
				console.warn("----ComB----sendOutside---->"+this.callbackValue);
				this.$emit('callBackFun',this.callbackValue);
			}
		},
		
		created() {
			uni.$on('getIntent',(msg) => {
				console.error("----ComB----getIntent----"+msg);
				this.result = msg;
			})
		}
	}
</script>

<style>
	.card {
		border-radius: 8px;
		padding: 10px;
		background-color: aquamarine;
		border: 1px solid #DDD;
		margin: 10px;
	}

	.title {
		font-size: 20px;
		text-align: center;
	}
	
	.area {
		margin: 10px;
	}
</style>